package com.jlcloud.core.oss.config;

import com.jlcloud.core.oss.rule.OssRule;
import io.minio.MinioClient;
import lombok.AllArgsConstructor;
import com.jlcloud.core.oss.LocalFileTemplate;
import com.jlcloud.core.oss.props.OssProperties;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * LocalFile配置类
 *
 * @author By: JlCloud <br>
 * @Package: com.jlcloud <br>
 * @CreateTime: 2024-12-03 21:45 <br>
 * @Copyright: 2021 www.jilianjituan.com Inc. All rights reserved. <br>
 * @Caution 注意：本内容仅限于冀联人力集团内部传阅，禁止外泄以及用于其他的商业目的 <br>
 */
@AllArgsConstructor
@AutoConfiguration(after = OssConfiguration.class)
@ConditionalOnClass({MinioClient.class})
@EnableConfigurationProperties(OssProperties.class)
@ConditionalOnProperty(value = "oss.name", havingValue = "local")
public class LocalFileConfiguration {

	private final OssProperties ossProperties;
	private final OssRule ossRule;

	@Bean
	@ConditionalOnMissingBean(LocalFileTemplate.class)
	public LocalFileTemplate localFileTemplate() {
		return new LocalFileTemplate(ossRule, ossProperties);
	}

}
